#ifndef COMMAND_H
#define COMMAND_H

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dirent.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>

#define PATHSTACK_MAXSIZE 128 // 目录级别
#define PATHNAME_MAXLEN 256
#define BUFSIZE 1024

typedef struct {
    char* pathArr[PATHSTACK_MAXSIZE];
    int top;
    int rootPathPointer; // 指向用户根目录在栈中的位置
} pathStack_t;

// 路径栈操作
int pathStackInit(pathStack_t* pathStack);
int popStack(pathStack_t* pathStack);
int pushStack(pathStack_t* pathStack, const char* str);
int destroyStack(pathStack_t* pathStack);
int saveStrPathToStack(char* path, pathStack_t* pathStack);
int getPath(const pathStack_t* pathStack, char* result);
int printPathStack(pathStack_t* pathStack);
int curPathInit(pathStack_t* pCurPathStack, char* rootPath);

// 文件操作命令
int my_cd(char* path, pathStack_t* pCurpathStack);
int my_ls(char* path, pathStack_t* pCurpathStack, char* result);
int my_rmFile(char* fileName, pathStack_t* pCurpathStack);
int my_pwd(pathStack_t* pCurPathStack, char* result);
int my_mkdir(char* dirName, pathStack_t* pCurpathStack);
int my_rmdir(char* dirName, pathStack_t* pCurpathStack);
int my_gets(char* srcPath,char* destPath,pathStack_t* pCurPathStack,char* returnFileName);
int my_puts(char* srcPath,char* destPath,pathStack_t* pCurPathStack);

#endif
